{{- if empty .Values.secret.externalSecretName }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "spilo-art.fullname" . }}
  labels:
    {{- include "spilo-art.labels" . | nindent 4 }}
type: Opaque
data:
  {{- if .Release.IsInstall }}
  superuser-password: {{ default (randAlphaNum 19 | nospace) .Values.secret.defaultPasswords.superuser | b64enc | quote }}
  replication-password: {{ default (randAlphaNum 19 | nospace) .Values.secret.defaultPasswords.replication | b64enc | quote }}
  admin-password: {{ default (randAlphaNum 19 | nospace) .Values.secret.defaultPasswords.admin | b64enc | quote }}
  {{ else }}
  superuser-password: {{ index (lookup "v1" "Secret" .Release.Namespace (include "spilo-art.fullname" .)).data "superuser-password" }}
  replication-password: {{ index (lookup "v1" "Secret" .Release.Namespace (include "spilo-art.fullname" .)).data "replication-password" }}
  admin-password: {{ index (lookup "v1" "Secret" .Release.Namespace (include "spilo-art.fullname" .)).data "admin-password" }}
  {{ end }}
{{- end }}